package cn.powertime.evaluation.service.impl;

import cn.powertime.evaluation.entity.CpsUserCollect;
import cn.powertime.evaluation.mapper.CpsUserCollectMapper;
import cn.powertime.evaluation.service.CpsUserCollectService;
import cn.powertime.evaluation.vo.RespAnswerTopicListVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户收藏试卷表 服务实现类
 * </p>
 *
 * @author liqi
 * @since 2019-09-23
 */
@Service
public class CpsUserCollectServiceImpl extends ServiceImpl<CpsUserCollectMapper, CpsUserCollect> implements CpsUserCollectService {

    @Autowired
    private CpsUserCollectMapper userCollectMapper;

    @Override
    public boolean add(CpsUserCollect userCollect) {
        return save(userCollect);
    }

    @Override
    public boolean delete(Long userId, Long topicId) {
        Integer i = userCollectMapper.batchDel(userId, topicId);
        return i > 0;
    }

    @Override
    public Page<RespAnswerTopicListVo> list(Page page, Long userId) {
        return this.userCollectMapper.selectPage(page, userId);
    }

}
